package com.xxx.video.commen.utils;

import android.text.TextUtils;

import com.xxx.video.VideoApplication;
import com.xxx.video.commen.views.CustomTipToast;


public class ToastUtils {
    public static boolean isShow = true;
    private static CustomTipToast mToast;

    /**
     * show error toast
     *
     * @param message error msg
     */
    public static void showError(String message) {
        if (isShow) {
            if (mToast == null) {
                mToast = CustomTipToast.makeText(VideoApplication.getInstance(), CustomTipToast.TYPE_ERROR, message);
            } else {
                mToast.setText(CustomTipToast.TYPE_ERROR, message);
            }
            if (!TextUtils.isEmpty(message)) {
                mToast.show();
            }
        }

    }

    /**
     * show success toast
     *
     * @param message error msg
     */
    public static void showSuccess(String message) {
        if (isShow) {
            if (mToast == null) {
                mToast = CustomTipToast.makeText(VideoApplication.getInstance(), CustomTipToast.TYPE_SUCCESS, message);
            } else {
                mToast.setText(CustomTipToast.TYPE_SUCCESS, message);
            }
            if (!TextUtils.isEmpty(message)) {
                mToast.show();
            }
        }
    }

    /**
     * cancel tip
     */
    public static void cancel() {
        if (mToast != null) {
            mToast.cancel();
        }
    }
}
